package view.tables;

import java.awt.Component;
import java.awt.SystemColor;
import java.text.DateFormat;
import java.util.Date;

import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;

import domain.Copy;
import domain.Copy.Condition;

@SuppressWarnings("serial")
public class IconizedTableCellRenderer extends DefaultTableCellRenderer {
	private static DateFormat dateFormat = DateFormat.getDateInstance();

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		JLabel cell = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		if(value instanceof IconizedInterface){
			IconizedInterface a = (IconizedInterface)value;
			
			cell.setIcon(a.getIcon());
			cell.setText(a.toString());
			
			return cell;
		} else if (value instanceof Date){
			Date d = (Date)value;
			cell.setText(dateFormat.format(d));
		}
		cell.setIcon(null);
		return cell;
	}

}
